package app.beit.finportal.service.convert;

import java.util.ArrayList;
import java.util.List;

import app.beit.finportal.bean.WebboardBean;
import app.beit.finportal.entity.WebboardReply;

public class WebboardReplyConvert {

	/**
	 * Convert Entity To Bean
	 * @param entity
	 * @return NewsBean
	 */
	public static WebboardBean entityToBean(final WebboardReply entity) throws Exception {
		final WebboardBean bean = new WebboardBean();
		
		bean.setId(entity.getId());
		bean.setWebboardId(entity.getWebboardId());
		bean.setContent(entity.getContent());
		bean.setIsAdmin(entity.getIsAdmin());
		bean.setCreatedBy(entity.getCreatedBy());
		bean.setCreatedDate(entity.getCreatedDate());
		
		return bean;
	}
	
	/**
	 * Convert Bean to Entity
	 * @param bean
	 * @return Webboard
	 */
	public static WebboardReply beanToEntity(final WebboardBean bean){
		final WebboardReply entity = new WebboardReply();

		entity.setId(bean.getId());
		entity.setWebboardId(bean.getWebboardId());
		entity.setContent(bean.getContent());
		entity.setIsAdmin(bean.getIsAdmin());
		entity.setCreatedBy(bean.getCreatedBy());
		entity.setCreatedDate(bean.getCreatedDate());
		
		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * @param entities
	 * @return List NewsBean
	 */
	public static List<WebboardBean> entityToBean(final List<WebboardReply> entities) throws Exception{
		final List<WebboardBean> beans = new ArrayList<WebboardBean>();
		
		for(final WebboardReply entity : entities){
			beans.add(WebboardReplyConvert.entityToBean(entity));
		}
		
		return beans;
	}
	
	/**
	 * Convert List Bean to List Entity
	 * @param beans
	 * @return List News
	 */
	public static List<WebboardReply> beanToEntity(final List<WebboardBean> beans){
		final List<WebboardReply> entities = new ArrayList<WebboardReply>();
		
		for(final WebboardBean bean : beans){
			entities.add(WebboardReplyConvert.beanToEntity(bean));
		}
		
		return entities;
	}
	
}
